Stream fusion : practical shortcut fusion for coinductive sequence types

نویسنده

  • Duncan Coutts
چکیده

In functional programming it is common practice to build modular programs by composing functions where the intermediate values are data structures such as lists or arrays. A desirable optimisation for programs written in this style is to fuse the composed functions and thereby eliminate the intermediate data structures and their associated runtime costs. Stream fusion is one such fusion optimisation that can eliminate intermediate data structures, including lists, arrays and other abstract data types that can be viewed as coinductive sequences. The fusion transformation can be applied fully automatically by a general purpose optimising compiler. The stream fusion technique itself has been presented previously and many practical implementations exist. The primary contributions of this thesis address the issues of correctness and optimisation: whether the transformation is correct and whether the transformation is an optimisation. Proofs of shortcut fusion laws have typically relied on parametricity by making use of free theorems. Unfortunately, most functional programming languages have semantics for which classical free theorems do not hold unconditionally; additional side conditions are required. In this thesis we take an approach based not on parametricity but on data abstraction. Using this approach we prove the correctness of stream fusion for lists – encompassing the fusion system as a whole, not merely the central fusion law. We generalise this proof to give a framework for proving the correctness of stream fusion for any abstract data type that can be viewed as a coinductive sequence and give as an instance of the framework, a simple model of arrays. The framework requires that each fusible function satisfies a simple data abstraction property. We give proofs of this property for several standard list functions. Previous empirical work has demonstrated that stream fusion can be an optimisation in many cases. In this thesis we take a more universal view and consider the issue of optimisation independently of any particular implementation or compiler. We make a semi-formal argument that, subject to certain syntactic conditions on fusible functions, stream fusion on lists is strictly an improvement, as measured by the number of allocations of data constructors. This detailed analysis of how stream fusion works may be of use in writing fusible functions or in developing new implementations of stream fusion. Copyright c ⃝ 2011 Duncan Coutts cbd This work is licensed under the Creative Commons Attribution-NoDerivs 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. This thesis is freely available in electronic form from the Oxford University Research Archive. http://ora.ox.ac.uk/

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Stream Fusion for Isabelle’s Code Generator

Stream fusion eliminates intermediate lists in functional code. We formalise stream fusion for finite and coinductive lists in Isabelle/HOL and implement the transformation in the code preprocessor. Our initial results show that optimisations during code extraction can boost the performance of the generated code, but the transformation requires further engineering to be usable in practice.

متن کامل

New characterizations of fusion bases and Riesz fusion bases in Hilbert spaces

In this paper we investigate a new notion of bases in Hilbert spaces and similar to fusion frame theory we introduce fusion bases theory in Hilbert spaces. We also introduce a new denition of fusion dual sequence associated with a fusion basis and show that the operators of a fusion dual sequence are continuous projections. Next we dene the fusion biorthogonal sequence, Bessel fusion basis, Hil...

متن کامل

In silico fusion of epsilon and beta toxin genes of Clostridium perfringens types D and B

Fusion protein technology represents the strategy to achieve rapid, efficient, and cost-effective proteinexpression. Epsilon and Beta toxins are the most potent Clostridial toxins and cause disease in animals.This study describes in silico fusion of Clostridium perfringens types D and B epsilon and beta toxin genesthat was used for cloning in E.coli. The etx and cpb genes were...

متن کامل

FUSION FRAMES IN HILBERT SPACES

Fusion frames are an extension to frames that provide a framework for applications and providing efficient and robust information processing algorithms. In this article we study the erasure of subspaces of a fusion frame.  

متن کامل

Multiple Intermediate Structure Deforestation by Shortcut Fusion

Shortcut fusion is a well-known optimization technique for functional programs. Its aim is to transform multi-pass algorithms into single pass ones, achieving deforestation of the intermediate structures that multi-pass algorithms need to construct. Shortcut fusion has already been extended in several ways. It can be applied to monadic programs, maintaining the global effects, and also to obtai...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2011